﻿<%@ Page Title="" Language="C#" MasterPageFile="~/masterPage/admin/Manage.master"
    AutoEventWireup="true" CodeFile="NewsManage.aspx.cs" Inherits="NewsManage" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">

    <div id="camanager" class="m_cate2">
        <h3>
            &copy;新闻管理</h3>
        <div class="con">
            <table cellspacing="0" cellpadding="4" class="Retrieval">
                <tr class="Retrieval_T">
                    <td width="60" rowspan="2">
                        <font>検索<br />
                            条件</font>
                    </td>
                    <td width="70">
                        <font>新闻分類</font>
                    </td>
                    <td>
                        <font>新闻作成者</font>
                    </td>
                    <td>
                        <font>新闻标题</font>
                    </td>
                    <td>
                        <font>新闻作成期间</font>
                    </td>
                    <td width="80">
                        <font>条件设置</font>
                    </td>
                </tr>
                <tr align="center" class="Retrieval_C">
                    <td>
                        <asp:DropDownList ID="dplCatagory" runat="server" DataSourceID="SqlDataSource1" DataTextField="CaName"
                            DataValueField="CaID">
                        </asp:DropDownList>
                    </td>
                    <td>
                        <asp:TextBox ID="tbUserName" CssClass="tb_RoleName" runat="server" MaxLength="20"></asp:TextBox>
                    </td>
                    <td>
                        <asp:TextBox ID="tbNewTitle" CssClass="tb_RoleName" runat="server" MaxLength="20"></asp:TextBox>
                    </td>
                    <td>
                        <telerik:RadDatePicker ID="dpCreateStDay" runat="server">
                        </telerik:RadDatePicker>
                        <asp:Label ID="Label1" runat="server" Text="～"></asp:Label>
                        <telerik:RadDatePicker ID="dpCreateEdDay" runat="server">
                        </telerik:RadDatePicker>
                    </td>
                    <td>
                        <asp:Button ID="Btn_Set" CssClass="Btn_Set" runat="server" Text="索引" OnClick="Btn_Set_Click" />
                    </td>
                </tr>
            </table>
            <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All"
                EnableRoundedCorners="false" />
            <telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
                <telerik:RadGrid ID="radGridMainlist" AllowPaging="True" AllowSorting="True" DataSourceID="sdsNewsList"
                    runat="server" AutoGenerateColumns="False" AllowMultiRowSelection="True"
                    OnItemCommand="radGridMainlist_ItemCommand" 
                    OnItemDataBound="radGridMainlist_ItemDataBound" Culture="ja-JP">
                    <PagerStyle FirstPageToolTip="首页" ShowPagerText="false" PagerTextFormat="{4}  当前{0}/{1}页, 条目({2}-{3})/{5}"
                        NextPagesToolTip="下页" Mode="NextPrevAndNumeric" PageSizeLabelText="单页数目" PrevPageToolTip="上页"
                        LastPageToolTip="末页" />
                    <HierarchySettings ExpandTooltip="查看评论信息" CollapseTooltip="收起" />
                    <MasterTableView DataKeyNames="CaID,NewsID" CommandItemDisplay="Top" ShowHeadersWhenNoRecords="true"
                        NoMasterRecordsText="该分類未创建新闻" AllowMultiColumnSorting="false"  Name="MainTable1">
                        <CommandItemTemplate>
                            &nbsp;&nbsp;
                            <asp:LinkButton ID="lbtBackup" runat="server" CommandName="SetBackup" ForeColor="Blue"
                                Font-Underline="true" Text="XXX" Visible="false" />&nbsp;&nbsp;
                        </CommandItemTemplate>
                        <EditFormSettings>
                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                            </EditColumn>
                        </EditFormSettings>
                        <CommandItemStyle BorderWidth="1" Height="30" />
                        <CommandItemSettings ExportToPdfText="Export to PDF" />
                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" 
                            Visible="True">
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" 
                            Visible="True">
                        </ExpandCollapseColumn>
                        <Columns>
                            <telerik:GridBoundColumn SortExpression="CaName" HeaderText="新闻分類" HeaderButtonType="LinkButton"
                                DataField="CaName" UniqueName="CaName">
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn UniqueName="Title" Groupable="False" HeaderText="新闻标题">
                                <ItemTemplate>
                                    <asp:Literal ID="Title" Text='<%# SalePartial.Utility.Utils.StringTruncate( DataBinder.Eval(Container.DataItem, "Title").ToString(), 20, "...")  %>'
                                        runat="server"></asp:Literal>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn UniqueName="CreateDate" DataField="CreateDate" Groupable="False"
                                HeaderText="创建时间">
                                <ItemTemplate>
                                    <asp:Literal ID="ltlCreateDate" Text='<%# DataBinder.Eval(Container.DataItem, "CreateDate") %>'
                                        runat="server"></asp:Literal>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn UniqueName="UserName" DataField="UserName" Groupable="False"
                                HeaderText="创建者">
                                <ItemTemplate>
                                    <asp:Literal ID="ltlUserName" Text='<%# SalePartial.Utility.Utils.StringTruncate(DataBinder.Eval(Container.DataItem, "UserName").ToString(), 10, "...") %>'
                                        runat="server"></asp:Literal>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn UniqueName="Content" Groupable="False" HeaderText="新闻内容">
                                <ItemTemplate>
                                    <asp:Literal ID="ltlContent" Text='<%# SalePartial.Utility.Utils.StringTruncate( DataBinder.Eval(Container.DataItem, "Content").ToString(), 50, "...") %>'
                                        runat="server"></asp:Literal>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn UniqueName="View" Groupable="False" HeaderText="查看内容">
                                <ItemTemplate>
                                    <asp:LinkButton ID="lbtView" runat="server" CommandName="View" Text="查看详情" CommandArgument="~/Management/News/AddNews.aspx"/>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridButtonColumn ButtonType="LinkButton" CommandName="ExpandCollapse" HeaderText="查看评论"
                                Groupable="false" Reorderable="false" Resizable="false" UniqueName="ExpandCollapse"
                                Text="查看评论">
                            </telerik:GridButtonColumn>
                            <telerik:GridTemplateColumn UniqueName="Update" Groupable="False" HeaderText="更新内容">
                                <ItemTemplate>
                                    <asp:LinkButton ID="lbtUpdate" runat="server" Text="更新" CommandName="Update" CausesValidation="false"  CommandArgument="~/Management/News/AddNews.aspx"/>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridButtonColumn Text="删除" CommandName="Delete" ButtonType="ImageButton" ConfirmTitle="删除" ConfirmText="将删除该新闻和评论，是否继续？">
                                                <HeaderStyle Width="2%" />
                                            </telerik:GridButtonColumn>
                        </Columns>

                        <DetailTables>
                                        <telerik:GridTableView AutoGenerateColumns="false" DataKeyNames="CoID" DataSourceID="sdsCommentDetail" NoDetailRecordsText="该新闻未创建评论"
                                           Name="DetailTable1" Width="100%">
                                            <ParentTableRelation>
                                                <telerik:GridRelationFields DetailKeyField="NewsID" MasterKeyField="NewsID"></telerik:GridRelationFields>
                                            </ParentTableRelation>
                                            <Columns>
                                             <telerik:GridTemplateColumn UniqueName="Content" Groupable="False" HeaderText="评论内容">
                                             <HeaderStyle Width="70%" />
                                <ItemTemplate>
                                    <asp:Literal ID="ltlCCoontent" Text='<%# SalePartial.Utility.Utils.StringTruncate( DataBinder.Eval(Container.DataItem, "Content").ToString(), 70, "...") %>'
                                        runat="server"></asp:Literal>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>

                             <telerik:GridTemplateColumn UniqueName="CreateDate" Groupable="False" HeaderText="创建时间">
                                <ItemTemplate>
                                    <asp:Literal ID="ltlCoCreateDate" Text='<%# DataBinder.Eval(Container.DataItem, "CreateDate") %>'
                                        runat="server"></asp:Literal>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>

                             <telerik:GridTemplateColumn UniqueName="UserIP" Groupable="False" HeaderText="创建者">
                                <ItemTemplate>
                                    <asp:Literal ID="ltlCoUserIP" Text='<%# DataBinder.Eval(Container.DataItem, "UserIP") %>'
                                        runat="server"></asp:Literal>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>

                            <telerik:GridButtonColumn Text="删除" CommandName="Delete" ButtonType="ImageButton" ConfirmTitle="删除" ConfirmText="将删除该评论，是否继续？">
                                                <HeaderStyle Width="2%" />
                            </telerik:GridButtonColumn>
                                            </Columns>
                                            </telerik:GridTableView>
                                    </DetailTables>

                    </MasterTableView>
                    <ClientSettings>
                        <Selecting AllowRowSelect="true" EnableDragToSelectRows="false" UseClientSelectColumnOnly="true" />
                    </ClientSettings>
                    <FilterMenu EnableImageSprites="False">
                    </FilterMenu>
                </telerik:RadGrid>
            </telerik:RadAjaxPanel>
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Metro" EnableEmbeddedSkins="false">
            </telerik:RadAjaxLoadingPanel>
        </div>
    </div>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:XunPanConnectionString %>"
        SelectCommand="SELECT CaID,CaName FROM [XPNewsCateGory]  ORDER BY CaID"></asp:SqlDataSource>
    <asp:SqlDataSource ID="sdsNewsList" runat="server" ConnectionString="<%$ ConnectionStrings:XunPanConnectionString %>"
        SelectCommand="SELECT C.CaID,C.CaName,N.NewsID,N.Title,N.Content,N.CreateDate, U.UserName FROM XPNewsCateGory C,XPNews N,  aspnet_Users U  WHERE  
                N.CaID = C.CaID and N.CreateUserID = U.UserId AND C.CaID =@CaID AND  U.UserName like @UserName
                 AND  N.Title like @Title AND N.CreateDate&gt;=@createStDay AND N.CreateDate&lt;=@createEdDay  ORDER BY N.NewsID">
               <SelectParameters>
            <asp:ControlParameter ControlID="dplCatagory" DefaultValue="0" Name="CaID" PropertyName="SelectedValue" />
            <asp:Parameter DefaultValue="%" Name="UserName"  />
            <asp:Parameter DefaultValue="19000101" Name="createStDay" />
            <asp:Parameter DefaultValue="20991231" Name="createEdDay" />
            <asp:Parameter DefaultValue="%" Name="Title"  />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="sdsCommentDetail" runat="server" ConnectionString="<%$ ConnectionStrings:XunPanConnectionString %>"
       SelectCommand="SELECT  C.CoID,C.Content,C.CreateDate,C.UserIP,N.NewsID FROM XPNewsComment C,XPNews N  WHERE  N.NewsID = C.NewsID and C.NewsID = @NewsID ORDER BY C.CreateDate">
            <SelectParameters>
            <asp:Parameter Name="NewsID" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
